package com.zhike.service.im.client;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import com.zhike.service.im.client.ConfigEntity.SenseMode;
import com.zhike.service.im.client.event.ChatBaseEventImpl;
import com.zhike.service.im.client.event.ChatMessageEventImpl;
import com.zhike.service.im.client.event.MessageQoSEventImpl;

import lombok.extern.slf4j.Slf4j;

@Component
@Slf4j
public class IMClientManager {

    /** 基本连接状态事件监听器 */
    @Autowired
    private ChatBaseEventImpl baseEventListener;

    /** 数据接收事件监听器 */
    @Autowired
    private ChatMessageEventImpl transDataListener;

    /** 消息送达保证事件监听器 */
    @Autowired
    private MessageQoSEventImpl messageQoSListener;

    @Autowired
    private ClientCoreSDK clientCoreSDK;

    private IMClientManager() {

    }

    /**
     * MobileIMSDK的初始化方法。
     */
    public void initMobileIMSDK() {
        // MobileIMSDK核心IM框架的敏感度模式设置
        ConfigEntity.setSenseMode(SenseMode.MODE_5S);

        // 设置事件回调
        clientCoreSDK.setChatBaseEvent(baseEventListener);
        clientCoreSDK.setChatMessageEvent(transDataListener);
        clientCoreSDK.setMessageQoSEvent(messageQoSListener);
    }

    public ChatMessageEventImpl getChatMessageListener() {
        return transDataListener;
    }

    public ChatBaseEventImpl getBaseEventListener() {
        return baseEventListener;
    }

    public MessageQoSEventImpl getMessageQoSListener() {
        return messageQoSListener;
    }
}
